home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
QRZ! Ham Radio 8
/
QRZ Ham Radio Callsign Database - Volume 8.iso
/
pc
/
files
/
t_unix
/
bs941029.tgz
/
bbsx-941029.tar
/
bbsx
/
sfstat.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-10-29
|
2KB
|
68 lines
#ifndef __lint
static char rcsid[] = "@(#) $Header: /home/dg1rtf/tcp/bbsx/RCS/sfstat.c,v 1.1 1994/06/01 22:21:32 dg1rtf Exp $";
#endif
#define _HPUX_SOURCE
#include <stdio.h>
#include <fcntl.h>
#include <pwd.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "bbs.h"
#include "bbs.hd"
const struct cmdtable cmdtable[1];
/* In sfstat.c: */
int main(int argc, char **argv);
/*---------------------------------------------------------------------------*/
int main(int argc, char **argv)
{
FILE * fp, *fp1;
char buf[1024];
char host[80];
char out[2048];
int fd;
int i;
struct index index;
struct passwd *pw;
unsigned long cycle;
cycle = (argc >= 2) ? atoi(argv[1]) : 0;
if (chdir(WRKDIR)) exit(1);
for (; ; ) {
if ((fd = open(INDEXFILE, O_RDONLY, 0644)) < 0) goto next;
if (lseek(fd, (long) (-sizeof(struct index )), 2) < 0) goto next;
if (read(fd, (char *) &index, sizeof(index)) != sizeof(index)) goto next;
if (!(fp = fopen(CONFIGFILE, "r"))) goto next;
if (cycle)
strcpy(out, "\033&a0y0C\033J");
else
*out = '\0';
while (fgets(buf, sizeof(buf), fp)) {
strlwc(buf);
if (sscanf(buf, "mbox:%s", host) < 1) continue;
if (!(pw = getpwnam(host))) continue;
sprintf(buf, "%s/" SEQFILE, pw->pw_dir);
if (!(fp1 = fopen(buf, "r"))) continue;
if (fscanf(fp1, "%d", &i) == 1)
sprintf(out + strlen(out), "%-6s %5d\n", pw->pw_name, index.mesg - i);
fclose(fp1);
}
fclose(fp);
write(1, out, strlen(out));
next:
if (!cycle) exit(0);
if (fd >= 0) close(fd);
sleep(cycle);
}
}